#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    audioRecorder = new QAudioRecorder;
    QAudioEncoderSettings audioSettings;
    audioSettings.setCodec("audio/amr");
    audioSettings.setQuality(QMultimedia::HighQuality);

    audioRecorder->setEncodingSettings(audioSettings);
    audioRecorder->setOutputLocation(QUrl::fromLocalFile("test.amr"));

    audioProbe = new QAudioProbe(this);
    if(audioProbe->setSource(audioRecorder)){
        connect(audioProbe,SIGNAL(audioBufferProbed(QAudioBuffer)),this,
                SLOT(calculateLevel(QAudioBuffer))
                );
    }



    audioRecorder->record();

}

Widget::~Widget()
{
}

void Widget::calculateLevel(const QAudioBuffer &buffer){
    Q_UNUSED(buffer);

    qDebug("buffer");
}

